package cn.org.xuanzp.send.handler;


import cn.hutool.json.JSONUtil;
import cn.org.xuanzp.common.command.Command;
import cn.org.xuanzp.common.utils.CommandUtils;
import cn.org.xuanzp.nty.server.handler.CommandHandler;
import cn.org.xuanzp.nty.utils.NettyServerUtil;

import java.util.Map;

/**
 * @Classname SendCommandHandler
 * @Description 消息发送handler
 * @Version 1.0.0
 * @Date 2024/9/22 23:55
 * @Created by xuanzp
 */

public class RouteCommandHandler implements CommandHandler {

    /***
     * 指令处理
     * @param command
     */
    @Override
    public void handler(Command command) {
        System.out.println("SendCommandHandler.command = " + JSONUtil.toJsonStr(command));
        Map headers = command.getHeaders();
        String toId = (String) headers.get(CommandUtils.COMMAND_HEADER_TO);
        NettyServerUtil.route(toId,command);

    }
}
